package com.ruoyi.park.service.impl;

import java.util.List;
import com.ruoyi.common.core.utils.DateUtils;
import cn.hutool.core.util.IdUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.common.core.utils.SecurityUtils;
import com.ruoyi.park.mapper.WyMaterialInOutMapper;
import com.ruoyi.park.domain.WyMaterialInOut;
import com.ruoyi.park.service.IWyMaterialInOutService;

/**
 * 物品出入管理Service业务层处理
 *
 * @author cjie
 * @date 2021-07-22
 */
@Service
public class WyMaterialInOutServiceImpl implements IWyMaterialInOutService {
    @Autowired
    private WyMaterialInOutMapper wyMaterialInOutMapper;

    /**
     * 查询物品出入管理
     *
     * @param id 物品出入管理ID
     * @return 物品出入管理
     */
    @Override
    public WyMaterialInOut selectWyMaterialInOutById(String id) {
        return wyMaterialInOutMapper.selectWyMaterialInOutById(id);
    }

    /**
     * 查询物品出入管理列表
     *
     * @param wyMaterialInOut 物品出入管理
     * @return 物品出入管理
     */
    @Override
    public List<WyMaterialInOut> selectWyMaterialInOutList(WyMaterialInOut wyMaterialInOut) {
        return wyMaterialInOutMapper.selectWyMaterialInOutList(wyMaterialInOut);
    }

    /**
     * 新增物品出入管理
     *
     * @param wyMaterialInOut 物品出入管理
     * @return 结果
     */
    @Override
    public int insertWyMaterialInOut(WyMaterialInOut wyMaterialInOut) {
        wyMaterialInOut.setId(IdUtil.getSnowflake(0, 0).nextIdStr());
        wyMaterialInOut.setCreateTime(DateUtils.getNowDate());
        wyMaterialInOut.setCreateBy(SecurityUtils.getUsername());
        return wyMaterialInOutMapper.insertWyMaterialInOut(wyMaterialInOut);
    }

    /**
     * 修改物品出入管理
     *
     * @param wyMaterialInOut 物品出入管理
     * @return 结果
     */
    @Override
    public int updateWyMaterialInOut(WyMaterialInOut wyMaterialInOut) {
        wyMaterialInOut.setUpdateTime(DateUtils.getNowDate());
        wyMaterialInOut.setUpdateBy(SecurityUtils.getUsername());
        return wyMaterialInOutMapper.updateWyMaterialInOut(wyMaterialInOut);
    }

    /**
     * 批量删除物品出入管理
     *
     * @param ids 需要删除的物品出入管理ID
     * @return 结果
     */
    @Override
    public int deleteWyMaterialInOutByIds(String[] ids) {
        return wyMaterialInOutMapper.deleteWyMaterialInOutByIds(ids);
    }

    /**
     * 删除物品出入管理信息
     *
     * @param id 物品出入管理ID
     * @return 结果
     */
    @Override
    public int deleteWyMaterialInOutById(String id) {
        return wyMaterialInOutMapper.deleteWyMaterialInOutById(id);
    }
}
